﻿using System.IO;

using System.Text;
using System;
using VOL.Core.Extensions;

namespace VOL.Core.Utilities
{
  public class DateTimeHelper
  {
		public static string FriendlyDate(DateTime? date)
		{
			if (!date.HasValue) return string.Empty;

			string strDate = date.Value.ToString("yyyy-MM-dd");
			string vDate = string.Empty;
			if(DateTime.Now.ToString("yyyy-MM-dd")==strDate)
			{
				vDate = "今天";
			}
			else if (DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") == strDate)
			{
				vDate = "明天";
			}
			else if (DateTime.Now.AddDays(2).ToString("yyyy-MM-dd") == strDate)
			{
				vDate = "后天";
			}
			else if (DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") == strDate)
			{
				vDate = "昨天";
			}
			else if (DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd") == strDate)
			{
				vDate = "前天";
			}
			else
			{
				vDate = strDate;
			}

			return vDate;
		}
		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		public static string CreateOrderNo()
        {
            return DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(1000, 9999);
        }
		
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static string CreateOrderNo(string orderExt,int countTotalPlanOrder)
        {
			return DateTime.Now.ToString("yyyyMMdd-") + orderExt + '-' + countTotalPlanOrder.ToString().PadLeft(4,'0');//new Random().Next(100, 999);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="proName"></param>
        /// <returns></returns>
        public static string CreateProgramNo(string proName)
        {
            return DateTime.Now.ToString("yyyyMMdd-") + proName + '-' + new Random().Next(100, 999);
        }
        public static string CreateNoDateProgramNo(string proName)
        {
            return proName + '-' + new Random().Next(100, 999);
        }
		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		public static long CreateNoTaskNo()
        {
			var firstno= DateTime.Now.ToString("yyyyMMdd").ToInt64().Value;
            return firstno+new Random().Next(100, 999).ToString().ToInt64().Value;
        }
    }
}

